 <?php
 session_start();
 include_once ("Login/databaseconnection.php");
 $current_table="deleted_resource_details";
 date_default_timezone_set("Europe/Paris");
  	$t_d=date("Y/m/d");
	$Resource_Id=$_GET['Resource_Id'];
	$Serial_Number=$_GET['Serial_Number'];
	$sqlre=mysql_query("SELECT * FROM deleted_resource_details");
	if(mysql_num_rows($sqlre)!=0)
	{
		$Resource_Id=$_POST['Resource_Id'];
		$Lab_Id=$_POST['Lab_Id'];
		$Serial_Number=$_POST['Serial_Number'];
		$Functioning=$_POST['Functioning'];
		$Brand_Name=$_POST['Brand_Name'];
		$Date_Of_Supplied=$_POST['Date_Of_Supplied'];
		$Name_Of_Supplier=$_POST['Name_Of_Supplier'];
		$Funding_Source=$_POST['Funding_Source'];
		$School_Id=$_POST['School_Id'];
		$Last_Updated_Date=$_POST['Last_Updated_Date'];
		$Accessed_By=$_POST['Accessed_By'];
		$_SESSION['Accessed_By']=$Accessed_By;
	$sql=mysql_query("INSERT INTO resource_details(Resource_Id,Lab_Id,Serial_Number,Functioning,Brand_Name,Date_Of_Supplied,Name_Of_Supplier,Funding_Source,School_Id,Last_Updated_Date)values('$Resource_Id','$Lab_Id','$Serial_Number','$Functioning','$Brand_Name','$Date_Of_Supplied','$Name_Of_Supplier','$Funding_Source','$School_Id','$t_d')");
if($sql)
{  $resultdel=mysql_query("DELETE FROM deleted_resource_details WHERE Resource_Id='$Resource_Id' AND Serial_Number='$Serial_Number'");
  if(!$resultdel)
{
	$sql=mysql_query("INSERT INTO resource_details(Resource_Id,Lab_Id,Serial_Number,Functioning,Brand_Name,Date_Of_Supplied,Name_Of_Supplier,Funding_Source,Last_Updated_Date,School_Id)values('$Resource_Id','$Lab_Id','$Serial_Number','$Functioning','$Brand_Name','$Date_Of_Supplied','$Name_Of_Supplier','$Funding_Source','$School_Id','$t_d')");
	 $_SESSION['error']="but this record is not removed from the recycle bin!";
}
$_SESSION['error']="Successfully restored!";
}
   if(!$sql)
{
	 $_SESSION['error']="Sorry,an error occured  please try again!";
}	
}
?>
